package com.fpt.dao;

import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

import org.junit.Test;

import com.fpt.common.valueobjects.PupilReportVO;

public class ReportDaoTest extends TestCase {

	// Test truong hop khi hoc ki nhap vao co gia tri < 1
	@Test
	public void testGetPupils_SemesterIsLowerThanOne_ReturnNull() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(-2, 2011, 1, "ds_hocsinh_trungbinh" );
		if(listPupilReportVO == null){
			assertTrue(true);
		}
		
	}
	
	
	// Test truong hop khi hoc ki nhap vao co gia tri > 3
	@Test
	public void testGetPupils_SemesterIsHigherThanThree_ReturnNull() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(4, 2011, 1, "ds_hocsinh_trungbinh" );
		if(listPupilReportVO == null){
			assertTrue(true);
		}
		
	}
	
	// Test truong hop khi hoc ki hop le, gia tri cua nam hoc < gia tri cua kieu Date trong SQL
	@Test
	public void testGetPupils_SemesterIsValidAndYearLowerThanMinValue_ReturnNull() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, 1900, 1, "thongtinlop" );
		if(listPupilReportVO == null){
			assertTrue(true);
		}
		
	}
	
	// Test truong hop khi hoc ki hop le, gia tri cua nam hoc > gia tri cua kieu Date trong SQL
	@Test
	public void testGetPupils_SemesterIsValidAndYearHigherThanMaxValue_ReturnNull() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, Integer.MAX_VALUE + 1, 1, "thongtinlop" );
		if(listPupilReportVO == null){
			assertTrue(true);
		}
		
	}
	
	// Test truong hop khi hoc ki hop le, gia tri cua nam hoc hop le, gia tri cua classId < 1
	@Test
	public void testGetPupils_SemesterIsValidAndYearIsValidAndClassIdLowerThanMinValue_ReturnNull() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, 2011, -2, "thongtinlop" );
		if(listPupilReportVO == null){
			assertTrue(true);
		}
		
	}
	
	
	
	// Test truong hop khi hoc ki hop le, gia tri cua nam hoc hop le, gia tri cua classId > gia tri MAX_INTEGER
	@Test
	public void testGetPupils_SemesterIsValidAndYearIsValidAndClassIdHigherThanMaxValue_ReturnNull() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, 2011, Integer.MAX_VALUE + 1, "thongtinlop" );
		if(listPupilReportVO == null){
			assertTrue(true);
		}
		
	}
	
	// Test truong hop khi hoc ki hop le, gia tri cua nam hoc hop le, gia tri cua classId hop le, gia tri cua tham so typePupils la NULL
	@Test
	public void testGetPupils_SemesterIsValidAndYearIsValidAndClassIdIsValidAndTypePupilsIsNull_ReturnNull() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, 2011, 2, null );
		if(listPupilReportVO == null){
			assertTrue(true);
		}
		
	}
	
	// Test truong hop khi hoc ki hop le, gia tri cua nam hoc hop le, gia tri cua classId hop le, gia tri cua tham so typePupils khong chinh xac
	@Test
	public void testGetPupils_SemesterIsValidAndYearIsValidAndClassIdIsValidAndTypePupilsIsNotCorrect_ReturnNull() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, 2011, 2, "abc" );
		if(listPupilReportVO == null){
			assertTrue(true);
		}
		
	}
	
	// Test truong hop khi hoc ki hop le, gia tri cua nam hoc hop le, gia tri cua classId hop le, gia tri cua tham so typePupils co chua chu so
	@Test
	public void testGetPupils_SemesterIsValidAndYearIsValidAndClassIdIsValidAndTypePupilsIsContatinDigits_ReturnNull() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, 2011, 2, "12" );
		if(listPupilReportVO == null){
			assertTrue(true);
		}
		
	}
	
	/* Test truong hop khi hoc ki hop le, gia tri cua nam hoc hop le, gia tri cua classId hop le, gia tri cua tham so typePupils dung de
	 truy van dua ve danh sach thong tin cac hoc sinh trong lop
	*/
	@Test
	public void testGetPupils_SemesterIsValidAndYearIsValidAndClassIdIsValidAndTypePupilsIsCorrect__ReturnListPupil() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, 2011, 2, "thongtinlop" );
		if(listPupilReportVO.size() == 12){
			assertTrue(true);
		}
		
	}
	
	/* Test truong hop khi hoc ki hop le, gia tri cua nam hoc hop le, gia tri cua classId hop le, gia tri cua tham so typePupils dung de
	 truy van dua ve danh sach thong tin cac hoc sinh gioi trong lop
	*/
	@Test
	public void testGetPupils_SemesterIsValidAndYearIsValidAndClassIdIsValidAndTypePupilsIsCorrect_ReturnListGoodPupil() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, 2011, 2, "ds_hocsinh_gioi" );
		if(listPupilReportVO.size() == 3){
			assertTrue(true);
		}
	}
	
	/* Test truong hop khi hoc ki hop le, gia tri cua nam hoc hop le, gia tri cua classId hop le, gia tri cua tham so typePupils dung de
	 truy van dua ve danh sach thong tin cac hoc sinh trung binh trong lop
	*/
	@Test
	public void testGetPupils_SemesterIsValidAndYearIsValidAndClassIdIsValidAndTypePupilsIsCorrect__ReturnListBadPupil() {
		ReportDao reportDao = new ReportDao();
		List <PupilReportVO> listPupilReportVO = new ArrayList<PupilReportVO>();
		listPupilReportVO = reportDao.getPupils(1, 2011, 2, "ds_hocsinh_trungbinh"  );
		if (listPupilReportVO.size() == 2){
			assertTrue(true);
		}
		
	}
	
	


}
